package com.demo02.offer01.numberof1inbinary;

public class Main {
    public static void main(String[] args) {
        int n = numberOf1(-15);
        System.out.println(n);
    }

    static int numberOf1(int n) {
        int count = 0;
        while (n != 0) {
            ++count;
            n = n & (n - 1);
        }
        return count;
    }
}
